<?php
echo html::printPath('userSpace.welcome-title', 'userSpace-welcome-desc');
$msg->printMessages();

/*
echo '<div style="color: red">';
echo '<ul>';
echo '<li>Lokální semináře</li>';
echo '<li>Mezinárodní semináře</li>';
echo '</ul>';
echo '</div>';
*/

if ($this->getAuthUser('is_admin')) {
    // Admis has access to all organizations
    echo '<h2>' . text::getEscaped('userSpace.organizations') . '</h2>';
    echo '<p class="description">' . text::getEscaped('userSpace.organizationsAdmin-info') . '</p>';
    
    $fb = new FormBuilder('person', array());
    $fb->setAction('/auth/switchOrganization');
    $fb->autocompleter('organization_id', $organizationOptions)->mustMatch()->labelKey('userSpace.adminEnterOrganization');
    $fb->write();
}
else {
    $organizerList = $this->getAuthUser('organizerList');
    $representativeList = $this->getAuthUser('representativeList');
    if ($organizerList || $representativeList) {
        echo '<h2>' . text::getEscaped('userSpace.organizations') . '</h2>';
        echo text::getEscaped('userSpace.organizations-info');
        if ($organizerList) {
            echo '<h3>' . text::getEscaped('userSpace.youAreOrganizerOfTheseOrgs') . ':</h3>';
            echo '<ul>';
            foreach ($organizerList as $organization) {
                echo '<li>' . html::anchor('/auth/switchOrganization?id=' . $organization['id'], $organization['name']) . ' (' . $organization['country']['name'] . ')</li>';
            }
            echo '</ul>';
        }

        if ($representativeList) {
            echo '<h3>' . text::getEscaped('userSpace.youAreRepOfTheseOrgs') . ':</h3>';
            echo '<ul>';
            foreach ($representativeList as $organization) {
                echo '<li>' . html::anchor('/auth/switchOrganization?id=' . $organization['id'], $organization['name']) . '</li>';
            }
            echo '</ul>';
        }
    }
}